package com.zsy.dao;

import com.zsy.pojo.Category;
import org.apache.ibatis.annotations.*;
import java.util.List;

@Mapper
public interface CategoryDao {

    @Insert("insert into category values(null,#{type},#{name},#{sort},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void save(Category category);

    @Select("SELECT * FROM category order by sort")
    List<Category> page();

    @Delete(" DELETE FROM category WHERE id=#{id};")
    void delete(long id);

    @Update("UPDATE category SET name=#{name},sort=#{sort},update_time=#{updateTime},update_user=#{updateUser} WHERE id=#{id}; ")
    void update(Category category);

    List<Category> findByType(@Param("type") Integer type);

    @Select("select * from category where id=#{id}")
    Category findById(Long id);
}
